<template>
  <div class="agent-item" :class="{'agent-item-clicked': type == 'click'}">
    <div class="avatar">
      <img :src="avatar ? staticHost + avatar : defaultAvatar" alt />
    </div>

    <div class="agent-info">
      <slot name="agent-info"></slot>
    </div>

    <div class="arrow" v-if="type == 'click'">
      <icon name="arrow" size="1.5rem" color="#DBD7DB" />
    </div>
  </div>
</template>

<script>
import { Icon } from "vant";
import { defaultAvatar } from "../service/default_source.js";
import {staticHost} from "../service/HOST.js"

export default {
  data() {
    return {
      staticHost,
      defaultAvatar,
    };
  },
  props: {
    avatar: {
      type: String,
    },
    type: {
      type: String,
      default: "click"
    }
  },
  components: {
    Icon
  }
};
</script>

<style scoped>
.agent-item {
  display: grid;
  grid-template-columns: 20% 75% 5%;
  grid-template-rows: 100%;
  text-align: left;
  padding: 15px;
  transition: 0.2s;
  border-top: 1px solid var(--line-between-color);
  border-bottom: 1px solid var(--line-between-color);
  background-color: #fff;
  font-size: 0.95rem;
}

.agent-item-clicked:hover {
  background-color: var(--line-between-color);
}

.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
}

.agent-info {
  padding-left: 5px;
}

.arrow {
  overflow: hidden;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.arrow img {
  width: 30px;
  max-height: 30px;
}
</style>